#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>

#include "Include/sysdefine.h"
#include "Log/inc/elog.h"
#include "MessageDispatcher/inc/messagedispatcher.h"

void logInit(void);

int main() {
    logInit(); // 初始化日志
    dispatcherTaskInit(); //初始化消息调度模块

    while(1)
    {
        tSysMsg sysMsg = { 0  };
         sysMsg.msgHead.wMsgLen  = 10;
         sysMsg.msgHead.bSrcTask = 1;
         sysMsg.msgHead.bDstTask = 2;
         sysMsg.msgHead.wFuncCode = 1;
         char buffer[] = "ni nihao niaoaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" ;
         memcpy(sysMsg.msgBody, buffer ,  sizeof(buffer));
        dispatcherApendMessage(&sysMsg);
    }
    return 0;
}


void logInit(void)
{
    elog_init();
    /* set EasyLogger log format */
    // elog_set_fmt(ELOG_LVL_ASSERT, ELOG_FMT_ALL);
    // elog_set_fmt(ELOG_LVL_ERROR, ELOG_FMT_LVL | ELOG_FMT_TAG | ELOG_FMT_TIME);
    // elog_set_fmt(ELOG_LVL_WARN, ELOG_FMT_LVL | ELOG_FMT_TAG | ELOG_FMT_TIME);
    // elog_set_fmt(ELOG_LVL_INFO, ELOG_FMT_LVL | ELOG_FMT_TAG | ELOG_FMT_TIME);
    // elog_set_fmt(ELOG_LVL_DEBUG, ELOG_FMT_ALL & ~(ELOG_FMT_FUNC | ELOG_FMT_T_INFO | ELOG_FMT_P_INFO));
    // elog_set_fmt(ELOG_LVL_VERBOSE, ELOG_FMT_ALL & ~(ELOG_FMT_FUNC | ELOG_FMT_T_INFO | ELOG_FMT_P_INFO));

    elog_set_fmt(ELOG_LVL_ASSERT, ELOG_FMT_ALL);
    elog_set_fmt(ELOG_LVL_ERROR, ELOG_FMT_ALL);
    elog_set_fmt(ELOG_LVL_WARN, ELOG_FMT_ALL);
    elog_set_fmt(ELOG_LVL_INFO, ELOG_FMT_ALL);
    elog_set_fmt(ELOG_LVL_DEBUG, ELOG_FMT_ALL);
    elog_set_fmt(ELOG_LVL_VERBOSE,ELOG_FMT_ALL);
    
    /* start EasyLogger */
    elog_start();
}